package com.yf.modules.security.model.convert;

import com.yf.domain.security.User;
import com.yf.modules.security.model.dto.UserDto;

/**
 * @author chentianwei
 * @date 2023/5/9 15:33
 * @description 用户转换器
 */
public class UserConvert {

    public static User convertModelToEntity(UserDto dto){
        User user = new User();
        user.setId(dto.getId());
        user.setEmail(dto.getEmail());
        user.setNickName(dto.getNickName());
        user.setIsAdmin(dto.getAdmin());
        user.setIsEnable(dto.getEnabled());
        user.setUserName(dto.getUsername());

        return user;
    }

    public static UserDto convertEntityToModel(User user){
        UserDto userDto = new UserDto();
        userDto.setId(user.getId());
        userDto.setEmail(user.getEmail());
        userDto.setEnabled(user.getIsEnable());
        userDto.setPassword(user.getPassword());
        userDto.setAdmin(user.getIsAdmin());
        userDto.setUsername(user.getUserName());
        userDto.setNickName(user.getNickName());
        userDto.setPhone(user.getPhone());

        return userDto;
    }
}
